package svgundoredo;

/**
 * This class for add element undo redo
 */
import svgedit.svg.SVGDocument;
import svgedit.svg.SVGElement;

public class AddElementCommand extends AbstractCommand
{
    private SVGElement elem;
    private SVGDocument document;
    
    /**
     * This constructor take the current space document and element
     * 
     * @param document
     *            current document
     * @param elem
     *            element to be add
     */
    public AddElementCommand(SVGDocument document, SVGElement elem)
    {
        this.document = document;
        this.elem = elem;
    }
    
    /**
     * This method is to execute as well to redo
     */
    @Override
    public void execute()
    {
        document.getRootGroup().appendChild(elem);
        
    }
    
    /**
     * This is undo method
     */
    @Override
    public void undo()
    {
        document.getRootGroup().removeChild(elem);
        
    }
    
}
